package fr.axgame;

public class Attack {

	private Character attacker;
	private Character defender;
	private int degats;
	private boolean dodge;
	private boolean critical;
	
	public Attack(Character attacker, Character defender){
		this.attacker = attacker;
		this.defender = defender;
		this.degats = 0;
		this.dodge = false;
		this.critical = false;
	}
	
	public Character getAttacker() {
		return attacker;
	}
	
	public void setAttacker(Character attacker) {
		this.attacker = attacker;
	}
	
	public Character getDefender() {
		return defender;
	}
	
	public void setDefender(Character defender) {
		this.defender = defender;
	}
	
	public int getDegats() {
		return degats;
	}
	
	public void setDegats(int degats) {
		this.degats = degats;
	}
	
	public boolean isDodge() {
		return dodge;
	}
	
	public void setDodge(boolean dodge) {
		this.dodge = dodge;
	}
	
	public boolean isCritical() {
		return critical;
	}
	
	public void setCritical(boolean critical) {
		this.critical = critical;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(attacker.getName() + " attacks " + defender.getName() + "!\n");
		if (dodge){
			sb.append(defender.getName() + " dodges !\n");
		} else {
			if (critical){
				sb.append("Critical Strike !\n");
			}
			sb.append(degats + " damages !\n");
		}
		if (defender.getCurrentLife() > 0){
			sb.append(defender.getName() + " has ");
			if (dodge){
				sb.append("still ");
			} else {
				sb.append("now ");
			}
			sb.append(defender.getCurrentLife() + " hp");
		} else {
			sb.append(defender.getName() + " loses. " + attacker.getName() + " wins");
		}
	    return sb.toString();
	}
	
}